package pers.qianyu.module.image.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import pers.qianyu.module.core.domain.image.entity.ImagePO;

import java.util.List;

@Mapper
public interface ImageDao extends BaseMapper<ImagePO> {
    @Select("select * from lamb_images where title regexp #{regex} and deleted = 0 and status = 0 order by create_time desc limit #{offset}, #{size}")
    List<ImagePO> selectImageByRegexOrderByCreateTime(@Param("regex") String regex,
                                                      @Param("offset") int offset,
                                                      @Param("size") int size);

    @Select("select count(1) from lamb_images where title regexp #{regex} and deleted = 0 and status = 0")
    long selectCountByRegex(@Param("regex") String regex);
}
